// desc：个人信息，顶部头像盒子块内容
import 'package:flutter/material.dart';

double _imgSize = 60.0;

class UserAvatarInfoWidget extends StatelessWidget {
  const UserAvatarInfoWidget({super.key});

  @override
  Widget build(BuildContext context) {

    // 左侧头像
    Widget avatarWidget = ClipRRect(
      borderRadius: BorderRadius.circular(8.0),
      child: Image.asset(
        'assets/images/lufei.png',
        width: _imgSize,
        height: _imgSize,
        fit: BoxFit.cover,
      ),
    );

    // 右侧的 二维码、箭头
    Widget rightBtnWidget = const Row(
      mainAxisAlignment: MainAxisAlignment.end,
      children: [
        Icon(Icons.qr_code, size: 14, color: Colors.grey,),
        SizedBox(width: 12.0),
        Icon(Icons.arrow_forward_ios, size: 12.0, color: Colors.grey),
      ],
    );

    // 状态图标
    Widget statusBtnWidget = SizedBox(
      height: 24.0,
      // ElevatedButton
      child: OutlinedButton.icon(
          onPressed: () {
            debugPrint('状态');
          },
          icon: const Icon(Icons.add, size: 12.0),
          label: const Text('状态', style: TextStyle(fontSize: 12.0, color: Color(0xFF6f6f6f))),
          style: ElevatedButton.styleFrom(
              backgroundColor: Colors.white,
              padding: EdgeInsets.zero,
              minimumSize: const Size(60, 20),
              foregroundColor: const Color(0xFF6f6f6f)
          )
      ),
    );

    // 刷新图标
    Widget refreshBtnWidget = SizedBox(
      height: 24.0,
      child: OutlinedButton(
        style: OutlinedButton.styleFrom(
            side: const BorderSide(color: Colors.grey),
            padding: EdgeInsets.zero,
            minimumSize: const Size(24, 20)
        ),
        onPressed: () {},
        child: const Icon(Icons.refresh, size: 16.0),
      ),
    );

    return Container(
      color: Colors.white,
      child: InkWell(
        child: Padding(
          padding: const EdgeInsets.fromLTRB(20, 0, 16, 20),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              avatarWidget, // 左侧头像
              const SizedBox(width: 10),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    const Text('前端没钱', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500)),
                    const SizedBox(height: 8.0),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        const Text('微信号：wx_user_name', style: TextStyle(color: Colors.grey)),
                        rightBtnWidget, // 二维码、箭头
                      ],
                    ),
                    const SizedBox(height: 8.0),
                    Row(
                      children: [
                        statusBtnWidget, // 状态图标
                        const SizedBox(width: 6),
                        refreshBtnWidget, // 刷新图标
                      ],
                    )
                  ],
                ),
              )
            ],
          ),
        ),
        onTap: () {
          Navigator.pushNamed(context, 'PersonInfoPage', arguments: {
            'test': '测试传参'
          });
        },
      ),
    );
  }
}
